import type { DoctorPage,PageParams,KnowledgePage, KnowledgeParams, FollowType,TopDep,Image, PartialConsult, ConsultOrderItem, ConsultOrderListParams, ConsultOrderPage } from '@/types/consult'
import { request } from '@/utiles/request'
import type { ConsultOrderPreData, ConsultOrderPreParams } from '@/types/consult'


export const getKnowledgePage = (params: KnowledgeParams) =>
    request.get<KnowledgePage>('/patient/home/knowledge', { params })
export const getDoctorPage = (params:PageParams)=>  request.get<DoctorPage>('/home/page/doc', { params})
export const followOrUnfollow = (id: string, type: FollowType = 'doc') =>request.post('/like', { id, type })
// 获取所有科室
export const getAllDep = () => request<TopDep[]>('/dep/all')
// 上传病情描述图片
export const uploadImage = (file: File) => {
    const fd = new FormData()
    fd.append('file', file)
    return request.post<Image>('/upload', fd)
}

// 拉取预支付订单信息
export const getConsultOrderPre = (params: ConsultOrderPreParams) =>
request.get<ConsultOrderPreData>('/patient/consult/order/pre', {params})
// 生成订单接口
export const createConsultOrder = (data:PartialConsult) => request.post<{id:string}>('/patient/consult/order', data)
// 获取支付地址
export const getPayUrl = (data:{
    paymentMethod:string,
    orderId:string,
    payCallback:string
}) => request.post<any>('/patient/consult/pay',data)
// 获取问诊订单详情
export const getConsultOrderDetail = (orderId: string) => request.get<any>('/patient/consult/order/detail', { params:{orderId} })
// 查看处方
// 查看处方
export const getPrescriptionPic = (id: string) =>
    request.get<{ url: string }>(`/patient/consult/prescription/${id}`)
// 评价问诊
export const evaluateConsultOrder = (data: {
    docId: string
    orderId: string
    score: number
    content: string
    anonymousFlag: 0 | 1
  }) => request.post<{ id: string }>('/patient/order/evaluate', data)
// 定义查询问诊订单列表接口
export const getConsultOrderList = (params: ConsultOrderListParams) =>
    request.get<ConsultOrderPage>('/patient/consult/order/list', { params })
// 取消订单
export const cancelOrder = ( id:string) => request.put('/patient/order/cancel/'+id)
// 删除订单
export const delOrder = (id:string) => request.delete('/patient/order/'+id)